{$CLEO}
const
    // general
    VehicleHandle = 0@
    VehicleStruct = 1@
    UnicalNumberOfCorona = 25@
    RpClump = 18@
    RwFrame = 19@
    CurrentCarOfPlayer = 15@
    OldCarOfPlayer = 16@
    StatusOfPlayerCar = 17@
    CamX = 12@
    CamY = 13@
    CamZ = 14@
    DamageManager = 23@
    CarDriver = 24@
    Timer = 32@
    
    // turnlights
    TractorStruct = 2@
    PointAdress = 2@
    Adress = 2@
    VectorPointer = 2@
    PrewPathPointID = 3@  //   
    CurrPathPointID = 4@
    NextPathPointID = 5@
    CarX = 6@
    PrewX = 6@            //  X  
    CarY = 7@
    CurrX = 7@
    CarZ = 8@
    NextX = 8@
    PrewY = 9@           //  Y  
    CurrY = 10@
    NextY = 11@
   
    //20@    
    //21@    
    //22@    
    TurnLightsStatus = 26@
    Angle1 = 27@
    Angle2 = 28@

    // :
    None = 0
    tLeft = 1
    tRight = 2
    tBoth = 3
    
    fR = 0.16
    uI = 100
    intensityA = 1
    distanceToGround = 0x40C00000
    colorR = 32
    colorG = 22
    colorB = 0
    
    char_pl = $player_char
    char_act = $player_actor
    
    STATE_DIS = 0
    STATE_OK = 1
    STATE_DAM = 2
    
    HEADLIGHT_LEFT = 0
    HEADLIGHT_RIGHT = 1
    LIGHT_RIGHT = 2
    LIGHT_LEFT = 3
    
    LF = 0
    RF = 1
    LR = 2
    RR = 3
    B_L = 4 
    B_R = 5
    R_L = 6
    R_R = 7
    F_L = 8
    F_R = 9
    T_LF = 10
    T_LM = 11
    T_LR = 12
    T_RF = 13
    T_RM = 14
    T_RR = 15
    
    LIGHT_STATES_OFFSET = 0x9E4
    
    _speed = 8.0
    _distance = 0.4
    
    _registerCorona = 0x6FC580
    _registerShadow = 0x707390
    _registerAmbientLight = 0x7000E0
    _getLightState = 0x6C2130 // int _getLightState(int eLight)
    _setLightState = 0x6C2100 // _setLightState(int eLight, int State)
    _getPanelState = 0x6C2180 // int _getPanelState(int ePanel)
    _RwFrame_GetLTM = 0x7F0990
end


// CScrEngine up
// NOP CScriptEngine__process's call
0A8C: write_memory 0x53BFC7 size 4 value 0x90909090 virtual_protect 1 
0A8C: write_memory 0x53BFCB size 1 value 0x90 virtual_protect 1 
// Call CScriptEngine__process() by overwriting a NOP call
0A8C: write_memory 0x53C215 size 4 value 0xF2DDE6E8 virtual_protect 1 
0A8C: write_memory 0x53C219 size 1 value 0xFF virtual_protect 1 

// MEMORY PATCH
0A8C: 0x6E1996 4 0x858624 1 // change fZero to fOne
0A8C: write_memory 0x6E1D4F size 1 value LIGHT_RIGHT virtual_protect 1

// --> included to ImVehLights.asi 
0A8C: 0x6E1996 4 0x858624 1 // change fZero to fOne
0A8C: 0x6E18E5 6 0x90 1   // camera stuff


// added from tail.lm 11-03-2012
0A8C: 0x6E28E7 5 0x90 1 // removes original PointLight for Vehicle backlights (works weird)
// test RGB
//0x8D368C 12 bytes could be unused! // end 11-03-2012

//BACKLIGHT CORONAS // <- +2 values
0AC6: 0@ = label @values offset
0a8c: 0@ 4 180.0 0
0a8c: 0x6E19D2 4 0@ 1
0a8c: 0x6E19B6 4 0@ 1
0@ += 4
0a8c: 0@ 4 0.3 0
0a8c: 0x6E1941 4 0@ 1
0a8c: 0x6E1A22 4 190 1

// init
OldCarOfPlayer = -1
// main loop
while true    
    wait 0
       
    // keyboard
    if
        player.defined(char_pl)
    then
        if
            actor.Driving(char_act)
        then    
            03C0: CurrentCarOfPlayer = actor char_act car
            046C: CarDriver = car CurrentCarOfPlayer driver
            if 
                003B: CarDriver == char_act
            then
                if
                    803B: not  CurrentCarOfPlayer == OldCarOfPlayer
                then
                    StatusOfPlayerCar = 0
                    0085: OldCarOfPlayer = CurrentCarOfPlayer
                end
                
                if
                    0AB0: key_pressed 90 // Z
                then
                    StatusOfPlayerCar = tLeft
                else
                    if
                        0AB0: key_pressed 88 // X
                    then
                        StatusOfPlayerCar = tBoth
                    else
                        if
                            0AB0: key_pressed 67 // C
                        then
                            StatusOfPlayerCar = tRight
                        else
                            if
                                0AB0: key_pressed 16 // Shift
                            then
                                StatusOfPlayerCar = None
                            end
                        end
                    end
                end
            end
        end
    end

    068D: get_camera_position_to CamX CamY CamZ
    0A9F: UnicalNumberOfCorona = current_thread_pointer
    
    // process lights
    0A8D: 22@ = read_memory 0xB74494 size 4 virtual_protect 0
    22@ += 0x4
    0A8D: 22@ = read_memory 22@ size 4 virtual_protect 0
    for 30@ = 0 to 27904 step 0x100
        0A8D: VehicleHandle = read_memory 22@ size 1 virtual_protect 0
        000A: 22@ += 0x1
        if and
            0029: VehicleHandle >= 0x00 
            001B: 0x80 > VehicleHandle
        then 
            005A: VehicleHandle += 30@
            0441: RpClump = car VehicleHandle model
            if or
                081F:   model RpClump plane
                0820:   model RpClump heli
                081E:   model RpClump boat
            then
                continue
            end
            0A97: VehicleStruct = car VehicleHandle struct
            0A8E: RpClump = VehicleStruct + 0x18
            0A8D: RpClump = read_memory RpClump size 4 virtual_protect 0
            0A8E: TractorStruct = VehicleStruct + 0x4C4
            0A8D: TractorStruct = read_memory TractorStruct size 4 virtual_protect 0
            0A8E: 8@ = VehicleStruct + LIGHT_STATES_OFFSET
            0A8C: write_memory 8@ size 16 value 0 virtual_protect 0 // reset lights info
            0A8E: DamageManager = VehicleStruct + 0x5A0
            0AA8: call_function_memethod _getLightState struct DamageManager num_params 1 pop 0 LIGHT_LEFT 20@
            0AA8: call_function_memethod _getLightState struct DamageManager num_params 1 pop 0 LIGHT_RIGHT 21@
            0441: 8@ = car VehicleHandle model
            if
                8A01: not model 8@ minimum_4wheels_vehicle
            then
                goto @cont
            end 
            if 20@ == 1
            then
                0A8E: 20@ = VehicleStruct + LIGHT_STATES_OFFSET
                20@ += B_L
                0A8C: 20@ 1 2 0 // TURN OFF
                0A8E: 20@ = VehicleStruct + LIGHT_STATES_OFFSET
                20@ += R_L
                0A8C: 20@ 1 2 0 // TURN OFF
                0A8E: 20@ = VehicleStruct + LIGHT_STATES_OFFSET
                20@ += T_LR
                0A8C: 20@ 1 2 0 // TURN OFF
            end
            if 21@ == 1
            then
                0A8E: 20@ = VehicleStruct + LIGHT_STATES_OFFSET
                20@ += B_R
                0A8C: 20@ 1 2 0 // TURN ON
                0A8E: 20@ = VehicleStruct + LIGHT_STATES_OFFSET
                20@ += R_R
                0A8C: 20@ 1 2 0 // TURN ON
                0A8E: 20@ = VehicleStruct + LIGHT_STATES_OFFSET
                20@ += T_RR
                0A8C: 20@ 1 2 0 // TURN ON
            end
            :cont
            if
                RpClump > 0
            then
                if and
                    TractorStruct <= 0
                    8686:  not car VehicleHandle attached
                then
                    0A8E: DamageManager = VehicleStruct + 0x5A0 
                    car.StorePos(VehicleHandle, CarX, CarY, CarZ)
                    046C: CarDriver = car VehicleHandle driver
                    0AB1: @reverselights 8 VehicleStruct VehicleHandle DamageManager CarDriver CamX CamY CamZ UnicalNumberOfCorona UnicalNumberOfCorona
                    0AB1: @breaklights 8 VehicleStruct VehicleHandle DamageManager CarDriver CamX CamY CamZ UnicalNumberOfCorona UnicalNumberOfCorona
                    //gosub @testbroke
                    //gosub @carlight
                    0AB1: @foglights 8 VehicleStruct VehicleHandle DamageManager CarDriver CamX CamY CamZ UnicalNumberOfCorona UnicalNumberOfCorona
                    //0085: 28@ VehicleHandle                    
                    //0085: VehicleHandle 28@
                    ////0A97: VehicleStruct = car VehicleHandle struct
                    //0A8E: DamageManager = VehicleStruct + 0x5A0
                    gosub @turnlights
                end
            end
        end
    end
end

:testbroke
0441: 8@ = car VehicleHandle model 
if
    0A01: model 8@ car // added 06-02-12
then
    0A8E: 8@ = VehicleStruct + 0xBC
    0A8D: 8@ = read_memory 8@ size 4 virtual_protect 0
    if
        8@ > 0 //   - ,   ,    entity 
    then
        0A8D: 27@ = read_memory 8@ size 4 virtual_protect 0
        if
            27@ == 0x871120 // CAutomobile _vmt
        then
            0AEB: 8@ = car_struct 8@ handle
            02E3: 20@ = car VehicleHandle speed
            if
                20@ > _speed
            then
                gosub @checkcollision
            else
                02E3: 20@ = car VehicleHandle speed 
                if
                    20@ > _speed
                then
                    0AB8: get_vehicle VehicleHandle current_gear_to 20@
                    if
                        20@ == 0
                    then
                        gosub @checkcollision
                    end
                end
            end
        else    
            02E3: 20@ = car VehicleHandle speed 
            if
                20@ > _speed
            then
                0AB8: get_vehicle VehicleHandle current_gear_to 20@
                if
                    20@ <> 10
                then
                    gosub @checkcollision
                end
            end
        end
    end
end
return

:checkcollision
// read data
0A8E: 8@ = VehicleStruct + 0xEC
0A8D: 3@ = read_memory 8@ size 4 virtual_protect 0
8@ += 4
0A8D: 4@ = read_memory 8@ size 4 virtual_protect 0
8@ += 4
0A8D: 5@ = read_memory 8@ size 4 virtual_protect 0

// get tailight position
0441: 20@ = car VehicleHandle model 
mul(20@, 4)
inc(20@, 0xA9B0C8) //  CModelBase
0A8D: 20@ = read_memory 20@ size 4 virtual_protect 0                                              
inc(20@, 0x5C)
0A8D: 20@ = read_memory 20@ size 4 virtual_protect 0
inc(20@, 0xC)
0A8D: 6@ = read_memory 20@ size 4 virtual_protect 0 // X
inc(20@, 4)
0A8D: 7@ = read_memory 20@ size 4 virtual_protect 0 // Y
inc(20@, 4)
0A8D: 8@ = read_memory 20@ size 4 virtual_protect 0 // Z

// RIGHT
0407: store_coords_to 9@ 10@ 11@ from_car VehicleHandle with_offset 6@ 7@ 8@
050A: 20@ = distance_between_XYZ 3@ 4@ 5@ and_XYZ 9@ 10@ 11@
if
    20@ < _distance
then
    0AA6: call_method _setLightState DamageManager num_params 2 pop flag 0 broken 1 LIGHT_RIGHT
end
// LEFT
6@ *= -1.0

0407: store_coords_to 9@ 10@ 11@ from_car VehicleHandle with_offset 6@ 7@ 8@

050A: 20@ = distance_between_XYZ 3@ 4@ 5@ and_XYZ 9@ 10@ 11@

if
    20@ < _distance
then
    0AA6: call_method _setLightState DamageManager num_params 2 pop flag 0 broken 1 LIGHT_LEFT
end
return            

{$I foglights.txt}
{$I breaklights.txt}
{$I reverselights.txt}

:turnlights
// check old car
if and
    803B:  not  VehicleHandle == OldCarOfPlayer
    CarDriver <= 0
then
    return
end
// check time
0A8E: 20@ = VehicleStruct + 0x9E0
0A8D: 20@ = read_memory 20@ size 4 virtual_protect 0
0085: 21@ = Timer
0062: 21@ -= 20@
if or
     21@ > 1000
     21@ < 0
then
     0A8E: 20@ = VehicleStruct + 0x9E0
     0A8C: write_memory 20@ size 4 value Timer virtual_protect 0
     return
else
    if
        21@ > 500
    then
        return
    end
end   
if
    003B: VehicleHandle == OldCarOfPlayer
then
    0085: TurnLightsStatus = StatusOfPlayerCar
    // right
    if or
        TurnLightsStatus == tRight
        TurnLightsStatus == tBoth
    then
        gosub @processRightLight
    end
    // left
    if or
        TurnLightsStatus == tLeft
        TurnLightsStatus == tBoth
    then
        gosub @processLeftLight
    end   
else
    TurnLightsStatus = 0
    0A8E: NextPathPointID = VehicleStruct + 0x3A6 // int            0x3A6
    0A8E: CurrPathPointID = VehicleStruct + 0x3A4 // int               0x3A4
    0A8E: PrewPathPointID = VehicleStruct + 0x3A8 // int           0x3A8
    0A8D: CurrPathPointID = read_memory CurrPathPointID size 2 virtual_protect 0
    0A8D: NextPathPointID = read_memory NextPathPointID size 2 virtual_protect 0
    0A8D: PrewPathPointID = read_memory PrewPathPointID size 2 virtual_protect 0
    if
        CurrPathPointID <> 0xFFFF
    then
        for 31@ = 0 to 2
            if
                3@(31@,3i) <> 0xFFFF
            then    
                0085: PointAdress = 3@(31@,3i) // (int) 
                
                0AC6: 20@ = label @SHR_0Ah offset
                0AA8: call_function_method 20@ struct 3@(31@,3i) num_params 0 pop 0 3@(31@,3i)
             //   0B15: 3@(31@,3i) = 3@(31@,3i) SHR 0xA   ////////////////////////////////////////////////////////////
             
                3@(31@,3i) *= 4
                3@(31@,3i) += 0x96F854
                0A8D: 3@(31@,3i) = read_memory 3@(31@,3i) size 4 virtual_protect 0
                    
                if
                    3@(31@,3i) <> 0
                then
                    0085: 3@(31@,3i) = PointAdress // (int)
    
                    0AC6: 20@ = label @AND_3FFh offset
                    0AA8: call_function_method 20@ struct PointAdress num_params 0 pop 0 PointAdress               
                 //   0B10: 0_PointAdress = 0_PointAdress AND 0x3FF ///////////////////////////////////////////////////
                   
                    PointAdress *= 0xE
                    
                    0AC6: 20@ = label @SHR_0Ah offset
                    0AA8: call_function_method 20@ struct 3@(31@,3i) num_params 0 pop 0 3@(31@,3i)                
                  //  0B15: 3@(31@,3i) = 3@(31@,3i) SHR 0xA ///////////////////////////////////////////////////////////
                   
                    3@(31@,3i) *= 4
                    3@(31@,3i) += 0x96F974
                    0A8D: 3@(31@,3i) = read_memory 3@(31@,3i) size 4 virtual_protect 0
                    005A: PointAdress += 3@(31@,3i) // (int) 
                            
                    0085: 6@(31@,3i) = PointAdress // (int)
                    0A8E: 9@(31@,3i) = PointAdress + 2 // int 
                            
                    0A8D: 6@(31@,3i) = read_memory 6@(31@,3i) size 2 virtual_protect 0
                    if
                        6@(31@,3i) >= 0x8000 // negative word
                    then
                        6@(31@,3i) += 0xFFFF0000 // convert to negative dword
                    end 
                    0093: 6@(31@,3i) = integer 6@(31@,3i) to_float 
                    6@(31@,3f) /= 8.0
                            
                    0A8D: 9@(31@,3i) = read_memory 9@(31@,3i) size 2 virtual_protect 0
                    if
                        9@(31@,3i) >= 0x8000 // negative word
                    then
                        9@(31@,3i) += 0xFFFF0000 // convert to negative dword
                    end 
                    0093: 9@(31@,3i) = integer 9@(31@,3i) to_float 
                    9@(31@,3f) /= 8.0   
                end
            else
                6@(31@,3i) = 0.0
                9@(31@,3i) = 0.0
            end // <> 0xFFFF          
        end   // for end    
    
        0063: NextX -= CurrX // (float) 
        0063: NextY -= CurrY // (float) 
        0063: CurrX -= PrewX // (float)
        0063: CurrY -= PrewY // (float) 
     
        0604: get_Z_angle_for_point NextX NextY store_to 20@
        0604: get_Z_angle_for_point CurrX CurrY store_to 21@
        0063: 20@ -= 21@ // (float)
        0656: get_angle 20@ absolute_degrees_to 20@
        if and
            20@ >= 30.0
            20@ < 180.0
        then
            TurnLightsStatus = tLeft
        else
            if and
                20@ <= 330.0
                20@ > 180.0
            then
                TurnLightsStatus = tRight
            else
                TurnLightsStatus = 0
            end
        end   // LightsStatus
        if
            TurnLightsStatus == tRight
        then
            gosub @processRightLight
        end
        if 
            TurnLightsStatus == tLeft
        then
            gosub @processLeftLight
        end        
    end   // FFFF    3A4     
end 

VehicleStruct += 0x4C8 
0A8D: VehicleStruct = read_memory VehicleStruct size 4 virtual_protect 0
0A8E: DamageManager = VehicleStruct + 0x5A0
if
    VehicleStruct > 0
then
    // ADD HERE
    0AEB: VehicleHandle = car_struct VehicleStruct handle
    if or
        TurnLightsStatus == tRight
        TurnLightsStatus == tBoth
    then
        gosub @processRightLight
    end
    if or
        TurnLightsStatus == tLeft
        TurnLightsStatus == tBoth
    then
        gosub @processLeftLight
    end    
end
  
return

:processRightLight
// front
0AA8: call_function_memethod _getLightState struct DamageManager num_params 1 pop 0 HEADLIGHT_RIGHT 21@
0441: 8@ = car VehicleHandle model
if
    8A01: not model 8@ minimum_4wheels_vehicle
then
    21@ = 0
end 
if
    21@ <> 1
then
    if
        0D0C: get_car VehicleHandle component "indicator_rf" matrix_to 21@ // IF and SET
    then
        0D07: get_coords CamX CamY CamZ offsets_relative_to_matrix 21@ store_to 6@ 7@ 8@
        21@ -= 0x10
        if
            7@ > 0.0
        then
            0AA5: _registerCorona 21 21 0 0 50.0 0 0.5 0 0 0 0 1 attach_corona_flare 0 type 1 150.0 radius fR with_offsets 21@ intensity uI blue 0 green 128 red 255 to_vehicle_struct VehicleStruct unical_number UnicalNumberOfCorona
        end
        UnicalNumberOfCorona += 1
        gosub @create_shadow
    end
    0A8E: 20@ = VehicleStruct + LIGHT_STATES_OFFSET
    20@ += T_RF
    0A8C: 20@ 1 1 0 // TURN ON
end
// middle
if
    0D0D: 21@ = get_car VehicleHandle component "indicator_rm" // IF and SET
then
    21@ += 0xA0  // RwFrame.Root
    0A8d: 20@ 21@ 4 0
    20@ += 0xAC
    0A8d: 6@ 20@ 4 0
    20@ += 4
    0a8d: 7@ 20@ 4 0
    if
        05AE: 6@s == 'wing_rf_' // if parent is a wing
    then
        // get wing status
        0AA8: call_function_method _getPanelState struct DamageManager num_params 1 pop 0 1 20@
        if
            20@ == 0
        then
            21@ -= 0x50
            0D07: get_coords CamX CamY CamZ offsets_relative_to_matrix 21@ store_to 6@ 7@ 8@
            21@ -= 0x10
            if
                7@ > 0.0
            then
                0AA5: _registerCorona 21 21 0 0 50.0 0 0.5 0 0 0 0 1 attach_corona_flare 0 type 1 150.0 radius fR with_offsets 21@ intensity uI blue 0 green 128 red 255 to_vehicle_struct VehicleStruct unical_number UnicalNumberOfCorona
            end
            UnicalNumberOfCorona += 1
            0A8E: 20@ = VehicleStruct + LIGHT_STATES_OFFSET
            20@ += T_RM
            0A8C: 20@ 1 1 0 // TURN ON
            gosub @create_shadow
        end
    else
        21@ -= 0x50
        0D07: get_coords CamX CamY CamZ offsets_relative_to_matrix 21@ store_to 6@ 7@ 8@
        21@ -= 0x10
        if
            7@ > 0.0
        then
            0AA5: _registerCorona 21 21 0 0 50.0 0 0.5 0 0 0 0 1 attach_corona_flare 0 type 1 150.0 radius fR with_offsets 21@ intensity uI blue 0 green 128 red 255 to_vehicle_struct VehicleStruct unical_number UnicalNumberOfCorona
        end
        UnicalNumberOfCorona += 1
        0A8E: 20@ = VehicleStruct + LIGHT_STATES_OFFSET
        20@ += T_RM
        0A8C: 20@ 1 1 0 // TURN ON
        gosub @create_shadow
    end
end
// back
0AA8: call_function_memethod _getLightState struct DamageManager num_params 1 pop 0 LIGHT_RIGHT 21@
0441: 8@ = car VehicleHandle model
if
    8A01: not model 8@ minimum_4wheels_vehicle
then
    21@ = 0
end 
if
    21@ <> 1
then
    if
        0D0C: get_car VehicleHandle component "indicator_rr" matrix_to 21@ // IF and SET
    then
        0D07: get_coords CamX CamY CamZ offsets_relative_to_matrix 21@ store_to 6@ 7@ 8@
        21@ -= 0x10
        if
            7@ > 0.0
        then
            0AA5: _registerCorona 21 21 0 0 50.0 0 0.5 0 0 0 0 1 attach_corona_flare 0 type 1 150.0 radius fR with_offsets 21@ intensity uI blue 0 green 128 red 255 to_vehicle_struct VehicleStruct unical_number UnicalNumberOfCorona
        end
        UnicalNumberOfCorona += 1
        gosub @create_shadow
    end
    0A8E: 20@ = VehicleStruct + LIGHT_STATES_OFFSET
    20@ += T_RR
    0A8C: 20@ 1 1 0 // TURN ON
end
return

:processLeftLight
// front
0AA8: call_function_memethod _getLightState struct DamageManager num_params 1 pop 0 HEADLIGHT_LEFT 21@
0441: 8@ = car VehicleHandle model
if
    8A01: not model 8@ minimum_4wheels_vehicle
then
    21@ = 0
end
if
    21@ <> 1
then
    if
        0D0C: get_car VehicleHandle component "indicator_lf" matrix_to 21@ // IF and SET
    then
        0D07: get_coords CamX CamY CamZ offsets_relative_to_matrix 21@ store_to 6@ 7@ 8@
        21@ -= 0x10
        if
            7@ > 0.0
        then
            0AA5: _registerCorona 21 21 0 0 50.0 0 0.5 0 0 0 0 1 attach_corona_flare 0 type 1 150.0 radius fR with_offsets 21@ intensity uI blue 0 green 128 red 255 to_vehicle_struct VehicleStruct unical_number UnicalNumberOfCorona
        end
        UnicalNumberOfCorona += 1
        gosub @create_shadow
    end
    0A8E: 20@ = VehicleStruct + LIGHT_STATES_OFFSET
    20@ += T_LF
    0A8C: 20@ 1 1 0 // TURN ON
end
// middle
if
    0D0D: 21@ = get_car VehicleHandle component "indicator_lm" // IF and SET
then
    21@ += 0xA0  // RwFrame.Root
    0A8d: 20@ 21@ 4 0
    20@ += 0xAC
    0A8d: 6@ 20@ 4 0
    20@ += 4
    0a8d: 7@ 20@ 4 0
    if
        05AE: 6@s == 'wing_lf_' // if parent is a wing
    then
        // get wing status
        0AA8: call_function_method _getPanelState struct DamageManager num_params 1 pop 0 0 20@
        if
            20@ == 0
        then
            21@ -= 0x50
            0D07: get_coords CamX CamY CamZ offsets_relative_to_matrix 21@ store_to 6@ 7@ 8@
            21@ -= 0x10
            if
                7@ > 0.0
            then
                0AA5: _registerCorona 21 21 0 0 50.0 0 0.5 0 0 0 0 1 attach_corona_flare 0 type 1 150.0 radius fR with_offsets 21@ intensity uI blue 0 green 128 red 255 to_vehicle_struct VehicleStruct unical_number UnicalNumberOfCorona
            end
            UnicalNumberOfCorona += 1
            0A8E: 20@ = VehicleStruct + LIGHT_STATES_OFFSET
            20@ += T_LM
            0A8C: 20@ 1 1 0 // TURN ON
            gosub @create_shadow
        end
    else
        21@ -= 0x50
        0D07: get_coords CamX CamY CamZ offsets_relative_to_matrix 21@ store_to 6@ 7@ 8@
        21@ -= 0x10
        if
            7@ > 0.0
        then
            0AA5: _registerCorona 21 21 0 0 50.0 0 0.5 0 0 0 0 1 attach_corona_flare 0 type 1 150.0 radius fR with_offsets 21@ intensity uI blue 0 green 128 red 255 to_vehicle_struct VehicleStruct unical_number UnicalNumberOfCorona
        end
        UnicalNumberOfCorona += 1
        0A8E: 20@ = VehicleStruct + LIGHT_STATES_OFFSET
        20@ += T_LM
        0A8C: 20@ 1 1 0 // TURN ON
        gosub @create_shadow
    end
end
// back
0AA8: call_function_memethod _getLightState struct DamageManager num_params 1 pop 0 LIGHT_LEFT 21@
0441: 8@ = car VehicleHandle model
if
    8A01: not model 8@ minimum_4wheels_vehicle
then
    21@ = 0
end 
if
    21@ <> 1
then
    if
        0D0C: get_car VehicleHandle component "indicator_lr" matrix_to 21@ // IF and SET
    then
        0D07: get_coords CamX CamY CamZ offsets_relative_to_matrix 21@ store_to 6@ 7@ 8@
        21@ -= 0x10
        if
            7@ > 0.0
        then
            0AA5: _registerCorona 21 21 0 0 50.0 0 0.5 0 0 0 0 1 attach_corona_flare 0 type 1 150.0 radius fR with_offsets 21@ intensity uI blue 0 green 128 red 255 to_vehicle_struct VehicleStruct unical_number UnicalNumberOfCorona
        end
        UnicalNumberOfCorona += 1
        gosub @create_shadow
    end
    0A8E: 20@ = VehicleStruct + LIGHT_STATES_OFFSET
    20@ += T_LR
    0A8C: 20@ 1 1 0 // TURN ON
end
return

:create_shadow
21@ -= 0x40
0AA5: _RwFrame_GetLTM 1 1 21@
21@ += 0x50
0D0A: store_coords_to 6@ 7@ 27@ from_matrix 21@ with_offsets 0.0 -1.0 0.0
0D0A: store_coords_to 8@ 9@ 27@ from_matrix 21@ with_offsets -1.1 0.0 0.0
0D0A: store_coords_to 3@ 4@ 5@  from_matrix 21@ with_offsets 0.0 0.0 0.0
0063: 6@ -= 3@                                                                                            
0063: 7@ -= 4@                                                                                            
0063: 8@ -= 3@                                                                                            
0063: 9@ -= 4@
0D0A: store_coords_to 3@ 4@ 5@  from_matrix 21@ with_offsets 0.0 1.2 0.0
0A8D: 20@ = read_memory 0xC4040C size 4 virtual_protect 0 //  4@  RwTexture lamp_shad64
0AC7: 21@ = var 3@ offset
0AA5: call _registerShadow num_params 16 pop 16 0 0 0x3F800000 0 distanceToGround colorB colorG colorR intensityA 9@ 8@ 7@ 6@ 21@ 20@ 2
return

:SHR_0Ah
hex
    C1 E9 0A          // shr ecx, 0xA
    89 C8             // mov eax, ecx
    C3                // retn
end

:AND_3FFh
hex
    81 E1 FF 03 00 00 // and ecx, 0x3FF
    89 C8             // mov eax, ecx
    C3                // retn
end

:values // <- here
hex
    00000000 00000000
end